<template>
  <div class="page">
    <div class="intro_tit">
      <h1>游戏策划课程</h1>
    </div>
<div style="width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;">
        <h1 style="font-size: 2.5em;
    font-weight: 100;
    margin-top: 60px;
    margin-bottom:0px;">课程介绍</h1>
        <img src="https://11092584.s61i.faiusr.com/4/AD0I6ISlBRAEGAAgm8TYvgUouajSMDDCAzgy.png" alt="">
        <p style="
            font-size: 18px;
            color: #555;
            line-height: 1.6;">了解更多关于游戏策划的内容，掌握游戏开发核心要点，探索创造无限可能。</p>
      </div>
    <div class="content">
      
      <div class="image-container">
        <!-- 第一张图片 -->
        <div class="image-box image-box-1">
          <img src="https://pic4.zhimg.com/v2-f73cd1dc0ea63605a6d2ec6f43dac172_1440w.jpg?source=172ae18b" alt="游戏世界的构建">
          <p class="image-description">了解更多关于游戏策划的内容，掌握游戏开发核心要点，探索创造无限可能。</p>
        </div>

        <div class="image-box-container">
          <!-- 右侧两张图片 -->
          <div class="image-box image-box-2">
            <img src="https://tse4-mm.cn.bing.net/th/id/OIP-C.IUNjmb-Dti4P3zet_Hg0swHaGg?rs=1&pid=ImgDetMain" alt="学校大楼2">
          </div>
          <div class="image-box image-box-2">
            <img src="https://tse3-mm.cn.bing.net/th/id/OIP-C.im5zQGD7K-KwViNA-qcgcAHaEM?rs=1&pid=ImgDetMain" alt="学校大楼3">
          </div>
        </div>
      </div>

      <div class="extra-info" style="text-align: left;
    padding-left: 30px;">
         <div v-html="course.content" class="content-html"></div>
      </div>
    </div>
  </div>
</template>

<script>
import { reactive } from 'vue';
import { getCourseIntro } from '@/services/home';

export default {
  setup() {
    const course = reactive({
      name: '游戏策划',
      image: 'https://re.bluepoch.com/home/img/backstory/p6.png',
      content: ''
    });

    return { course };
  },
  methods: {
    getIntro() {
      getCourseIntro(1).then(res => {
        this.course.content = res.data.data;
      }).catch(err => {
        console.log(err);
      });
    },
     addScrollAnimation() {
      const observer = new IntersectionObserver((entries) => {
        entries.forEach(entry => {
          if (entry.isIntersecting) {
            entry.target.classList.add('active');
          }
        });
      }, { threshold: 0.3 });

      const imageContainer = document.querySelector('.image-container');
      if (imageContainer) observer.observe(imageContainer);
    }
    
  },
  mounted() {
    this.getIntro(); 
    this.addScrollAnimation();
  }
};
</script>

<style scoped>
/* 页面整体样式 */
.page {
  font-family: 'Poppins', Arial, sans-serif;
  background-color:white;
  text-align: center;
}

/* 头部大图 */
.intro_tit {
  height: 400px;
  background-image: url('https://www.westlake.edu.cn/academics/library/ylfw/202212/W020230207337959103579.jpg'); 
  background-size: cover;
  background-position: center;
  display: flex;
  justify-content: center;
  align-items: center;
  color: white;
  font-size: 36px;
  font-weight: bold;
  box-shadow: 0px 4px 6px rgba(0, 0, 0, 0.1);
  margin-top: -10px;
}

/* 课程介绍 */
.content {
  max-width: 1200px;
  margin: 80px auto;
  padding: 20px;
  border-radius: 12px;
  display: flex;
  justify-content: space-between;
}

/* 图片容器 */
.image-container {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  width: 50%;
  opacity: 0;
  transition: all 0.6s ease-out;
}
.image-container.active {
  opacity: 1;
}
/* 图片盒子 */
.image-box {
  position: relative;
  background-color: #fafafa;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* 第一张图片 */
.image-box-1 {
  height: 420px;
  width: 100%;
  animation: slideInLeft 0.8s ease-out forwards;
}

.image-box-1 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.image-box-1 .image-description {
  position: absolute;
  bottom: 0;
  width: 93%;
  padding: 10px;
  background: rgba(0, 0, 0, 0.6);
  color: white;
  font-size: 18px;
  display: none;
}

.image-box-1:hover .image-description {
  display: block;
}

/* 右侧两张图片样式 */
.image-box-container {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  animation: slideInRight 0.8s ease-out forwards;
}

.image-box-2 {
  height: 200px;
}

.image-box-2 img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

/* 额外信息 */
.extra-info {
  width: 50%;
  font-size: 18px;
  color: #555;
  line-height: 1.6;
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInRight {
  from {
    transform: translateX(100px);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

/* 响应式适配 */
@media (max-width: 768px) {
  .image-container {
    width: 100%;
    flex-direction: column;
    gap: 40px;
    opacity: 1;
  }
  
  .image-box-1,
  .image-box-container {
    animation: none;
    transform: none;
    opacity: 1;
  }
}

</style>
